# -*- coding: utf-8 -*-
from model import Collection, db
from time import time


class StudioComment(Collection):
    '''
* `_id` (ObjectId) - Object ID of comment
* `fromUserId` (string) - 评论者的 ID
* `content` (string) - content of comment
* `reply` (string) - 画室的回复
* `timestamp` (long) - timestamp of comment
* `studioId` (string) - 这条评论是哪个画室下的
    '''

    collection = db.studio.comment

    class Field(object):
        _id = '_id'
        fromUserId = 'fromUser'
        content = 'content'
        reply = 'reply'
        timestamp = 'timestamp'
        studioId = 'studioId'

    @staticmethod
    def new_studio_comment(from_user, content, studio_id):
        return StudioComment.insert({
            StudioComment.Field.fromUserId: from_user,
            StudioComment.Field.content: content,
            StudioComment.Field.reply: '',
            StudioComment.Field.timestamp: int(time() * 1000),
            StudioComment.Field.studioId: studio_id
        })
